package com.usian.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.usian.pojo.Goods;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GoodsMapper extends BaseMapper<Goods> {
    //查询提交审核的人数
    @Select("select count(*) from goods where id in (#{ids}) and status2=1")
    Integer selectStatus2(String ids);

    //查询审核失败的商品个数
    @Select("select count(*) from goods where id in (#{ids}) and status3=0")
    Integer selectStatus3(String ids);

    //根据商品名称统计上架的商品个数
    @Select("select count(*) from goods where name=#{name} and status4=1")
    Integer selectName(String name);

    //根据商品名称统计商品个数
    @Select("select count(*) from goods where name=#{name}")
    Integer selectName2(String name);

    //根据商品名称查询商品ID
    @Select("select id from goods where name=#{name} and status4=1")
    Integer selectName3(String name);

    //修改状态
    @Update("update goods set status2=0,status3=0,num3=1 where id!=#{id} and name=#{name}")
    void edit(String name, Integer id);

    //查询是否启用
    @Select("select count(*) from goods where id in (#{ids}) and status1=1")
    Integer selectStatus1(String ids);

    //查询上架的商品信息
    @Select("select * from goods where status4=1")
    List<Goods> selectStatus4();
}











